import React from "react";
import { Input, Button, Space, Table } from 'antd';
import './newPlan.css'
import { useState } from 'react';
import axios from 'axios'

export default function NewPlan() {
  const columns = [
    {
      title: '序号',
      dataIndex: 'name',//'userName'
      key: 1,
    },
    {
      title: '计算公式',
      dataIndex: 'userType',
      key:2,
    },
    {
      title: '计算条件',
      dataIndex: 'baseName',
      key: 3,
    },
    {
      title: '操作',
      key: 4,
      render: (_, record) => (
        <Space size="middle">
          <a>作废</a>
        </Space>
      ),
    },
  ];
  // 在函数式组件里面使用useSate来定义了数据 []就是初始值 setDate是在给data赋值时使用
  let [data, setDate] = useState([]);
  
  componentDidMount=() =>{
    axios.get('', {
      params: {
        pagesize: 10,
        pagenum: 1,
      }
    })
      .then(response => {
        // setDate(data)
      })
      .catch(function (error) {
        // console.log(error);
      })
  }

  return <>

    <div>
      <label>方案名称：</label><span></span><Input placeholder="请输入方案名称" className="inputName" />
      <Button className="addBtn">添加明细</Button>
      <Table columns={columns} dataSource={data} className="tb" />
    </div>

  </>
}